package com.lghs.stutor;

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.net.ConnectivityManager;
import android.util.Log;

public class Vital extends Activity {

    public boolean logthekitty = false;
    public String host = "devpump.dyndns.org" + "/stutor";// "devpump.dyndns.org";

    public void alertsystem(final Alertresponder classname, String alerttitle,
                            String alertmessage, String buttonamount, String buttonreason,
                            String alertposbutton, String alertneubutton, String alertnegbutton) {
        AlertDialog.Builder alertDialog = new AlertDialog.Builder(
                (Activity) classname);
        alertDialog.setTitle(alerttitle);
        alertDialog.setMessage(alertmessage);
        alertDialog.setIcon(R.drawable.error);
        if (buttonreason.contains("green"))
            alertDialog.setIcon(R.drawable.green);
        if (buttonreason.contains("idk"))
            alertDialog.setIcon(R.drawable.idk);
        if (buttonreason.contains("bad"))
            alertDialog.setIcon(R.drawable.error);
        if (buttonamount.contains("1")) {
            alertDialog.setPositiveButton(alertposbutton,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            classname.buttonhandler(1);
                        }
                    });
        }
        if (buttonamount.contains("2")) {
            alertDialog.setNeutralButton(alertneubutton,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            classname.buttonhandler(2);
                        }
                    });
        }

        if (buttonamount.contains("3")) {
            alertDialog.setNegativeButton(alertnegbutton,
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            classname.buttonhandler(3);
                        }
                    });
        }
        alertDialog.show();
    }

    public void checkInternetConnection(final Alertresponder classname, ConnectivityManager cm) {

        if (cm.getActiveNetworkInfo() != null
                && cm.getActiveNetworkInfo().isAvailable()
                && cm.getActiveNetworkInfo().isConnected()) {
            if (logthekitty)
                Log.v("Network Status: ", "Internet Connection Present");
            classname.internethandler(1);
        } else {
            if (logthekitty)
                Log.v("Network Status: ", "Internet Connection Not Present");
            classname.internethandler(2);
        }
    }
}